﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <div>
    <el-form ref="formRefProductionOrder" :model="stateProductionOrder.vmModel" label-width="100px">
      <el-row>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_PlanId_FormItem" prop="Entity.PlanId" :label="$t('message.autotrans._Model_ProductionOrder_Plan')">
            <el-select v-model="stateProductionOrder.vmModel.Entity.PlanId" disabled clearable>
               <el-option v-for="item in stateProductionOrder.AllPlans" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ProductId_FormItem" prop="Entity.ProductId" :label="$t('message.autotrans._Model_ProductionOrder_ProductId')">
            <el-input v-model="stateProductionOrder.vmModel.Entity.ProductId" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ProductCode_FormItem" prop="Entity.ProductCode" :label="$t('message.autotrans._Model_ProductionOrder_ProductCode')">
            <el-input v-model="stateProductionOrder.vmModel.Entity.ProductCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ProductName_FormItem" prop="Entity.ProductName" :label="$t('message.autotrans._Model_ProductionOrder_ProductName')">
            <el-input v-model="stateProductionOrder.vmModel.Entity.ProductName" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Wo_FormItem" prop="Entity.Wo" :label="$t('message.autotrans._Model_ProductionOrder_Wo')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProductionOrder_Wo')}), trigger: 'blur' }]" >
            <el-input v-model="stateProductionOrder.vmModel.Entity.Wo" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_PlanQty_FormItem" prop="Entity.PlanQty" :label="$t('message.autotrans._Model_ProductionOrder_PlanQty')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProductionOrder_PlanQty')}), trigger: 'blur' }]" >
            <el-input v-model="stateProductionOrder.vmModel.Entity.PlanQty" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_OnlineQty_FormItem" prop="Entity.OnlineQty" :label="$t('message.autotrans._Model_ProductionOrder_OnlineQty')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProductionOrder_OnlineQty')}), trigger: 'blur' }]" >
            <el-input v-model="stateProductionOrder.vmModel.Entity.OnlineQty" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_CompletedQty_FormItem" prop="Entity.CompletedQty" :label="$t('message.autotrans._Model_ProductionOrder_CompletedQty')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProductionOrder_CompletedQty')}), trigger: 'blur' }]" >
            <el-input v-model="stateProductionOrder.vmModel.Entity.CompletedQty" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_QualifiedQty_FormItem" prop="Entity.QualifiedQty" :label="$t('message.autotrans._Model_ProductionOrder_QualifiedQty')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProductionOrder_QualifiedQty')}), trigger: 'blur' }]" >
            <el-input v-model="stateProductionOrder.vmModel.Entity.QualifiedQty" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_UnqualifiedQty_FormItem" prop="Entity.UnqualifiedQty" :label="$t('message.autotrans._Model_ProductionOrder_UnqualifiedQty')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProductionOrder_UnqualifiedQty')}), trigger: 'blur' }]" >
            <el-input v-model="stateProductionOrder.vmModel.Entity.UnqualifiedQty" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ScrapQty_FormItem" prop="Entity.ScrapQty" :label="$t('message.autotrans._Model_ProductionOrder_ScrapQty')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProductionOrder_ScrapQty')}), trigger: 'blur' }]" >
            <el-input v-model="stateProductionOrder.vmModel.Entity.ScrapQty" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_PlanStartTime_FormItem" prop="Entity.PlanStartTime" :label="$t('message.autotrans._Model_ProductionOrder_PlanStartTime')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProductionOrder_PlanStartTime')}), trigger: 'blur' }]" >
            <el-input v-model="stateProductionOrder.vmModel.Entity.PlanStartTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_PlanEndTime_FormItem" prop="Entity.PlanEndTime" :label="$t('message.autotrans._Model_ProductionOrder_PlanEndTime')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProductionOrder_PlanEndTime')}), trigger: 'blur' }]" >
            <el-input v-model="stateProductionOrder.vmModel.Entity.PlanEndTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ActualStartTime_FormItem" prop="Entity.ActualStartTime" :label="$t('message.autotrans._Model_ProductionOrder_ActualStartTime')">
            <el-input v-model="stateProductionOrder.vmModel.Entity.ActualStartTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ActualEndTime_FormItem" prop="Entity.ActualEndTime" :label="$t('message.autotrans._Model_ProductionOrder_ActualEndTime')">
            <el-input v-model="stateProductionOrder.vmModel.Entity.ActualEndTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_OrderStatus_FormItem" prop="Entity.OrderStatus" :label="$t('message.autotrans._Model_ProductionOrder_OrderStatus')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProductionOrder_OrderStatus')}), trigger: 'blur' }]" >
            <el-select v-model="stateProductionOrder.vmModel.Entity.OrderStatus" disabled clearable>
               <el-option key="Created" value="Created" :label="$t('message.autotrans._Enum_WoStatusEnum_Created')"></el-option>
               <el-option key="Scheduled" value="Scheduled" :label="$t('message.autotrans._Enum_WoStatusEnum_Scheduled')"></el-option>
               <el-option key="Issued" value="Issued" :label="$t('message.autotrans._Enum_WoStatusEnum_Issued')"></el-option>
               <el-option key="Executing" value="Executing" :label="$t('message.autotrans._Enum_WoStatusEnum_Executing')"></el-option>
               <el-option key="Completed" value="Completed" :label="$t('message.autotrans._Enum_WoStatusEnum_Completed')"></el-option>
               <el-option key="Paused" value="Paused" :label="$t('message.autotrans._Enum_WoStatusEnum_Paused')"></el-option>
               <el-option key="Freezed" value="Freezed" :label="$t('message.autotrans._Enum_WoStatusEnum_Freezed')"></el-option>
               <el-option key="Canceled" value="Canceled" :label="$t('message.autotrans._Enum_WoStatusEnum_Canceled')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_OrderSource_FormItem" prop="Entity.OrderSource" :label="$t('message.autotrans._Model_ProductionOrder_OrderSource')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProductionOrder_OrderSource')}), trigger: 'blur' }]" >
            <el-select v-model="stateProductionOrder.vmModel.Entity.OrderSource" disabled clearable>
               <el-option key="Local" value="Local" :label="$t('message.autotrans._Enum_WoSourceEnum_Local')"></el-option>
               <el-option key="Erp" value="Erp" :label="$t('message.autotrans._Enum_WoSourceEnum_Erp')"></el-option>
               <el-option key="MOM" value="MOM" :label="$t('message.autotrans._Enum_WoSourceEnum_MOM')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Sort_FormItem" prop="Entity.Sort" :label="$t('message.autotrans._Model_ProductionOrder_Sort')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProductionOrder_Sort')}), trigger: 'blur' }]" >
            <el-input v-model="stateProductionOrder.vmModel.Entity.Sort" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_CreateTime_FormItem" prop="Entity.CreateTime" :label="$t('message.autotrans._Model_ProductionOrder_CreateTime')">
            <el-input v-model="stateProductionOrder.vmModel.Entity.CreateTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_UpdateTime_FormItem" prop="Entity.UpdateTime" :label="$t('message.autotrans._Model_ProductionOrder_UpdateTime')">
            <el-input v-model="stateProductionOrder.vmModel.Entity.UpdateTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_CreateBy_FormItem" prop="Entity.CreateBy" :label="$t('message.autotrans._Model_ProductionOrder_CreateBy')">
            <el-input v-model="stateProductionOrder.vmModel.Entity.CreateBy" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_UpdateBy_FormItem" prop="Entity.UpdateBy" :label="$t('message.autotrans._Model_ProductionOrder_UpdateBy')">
            <el-input v-model="stateProductionOrder.vmModel.Entity.UpdateBy" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_IsValid_FormItem" prop="Entity.IsValid" :label="$t('message.autotrans._Model_ProductionOrder_IsValid')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProductionOrder_IsValid')}), trigger: 'blur' }]" >
            <el-input v-model="stateProductionOrder.vmModel.Entity.IsValid" disabled clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

      <div style="text-align:right;">
        <WtmButton @click="onCloseProductionOrder"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

      </div>

    </el-form>

  </div>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PagePlanningManagementProductionOrderDetails;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { productionorderApi } from '/@/api/planningmanagement/productionorder';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefProductionOrder = ref();
const stateProductionOrder = reactive({
    vmModel: {
	  Entity:{
        PlanId: null,
        ProductId: null,
        ProductCode: '',
        ProductName: '',
        Wo: '',
        PlanQty: null,
        OnlineQty: null,
        CompletedQty: null,
        QualifiedQty: null,
        UnqualifiedQty: null,
        ScrapQty: null,
        PlanStartTime: undefined,
        PlanEndTime: undefined,
        ActualStartTime: undefined,
        ActualEndTime: undefined,
        OrderStatus: undefined,
        OrderSource: undefined,
        Sort: null,
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
        IsValid: undefined,
        ID:null,
      },

	},
    
    AllPlans: [] as any[],
});

// 取消
const onCloseProductionOrder = () => {
    closeDialog();
};

// 提交
const onSubmitProductionOrder = () => {
 	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});
   formRefProductionOrder.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            productionorderApi().edit(stateProductionOrder.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
        else{
			loadingInstance.close();
        }
	})
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/PlanningManagement/ProductionOrder/GetProductionPlannings',[],false).then(x=>{stateProductionOrder.AllPlans = x});
    if (ci.attrs["wtmdata"]) {
		stateProductionOrder.vmModel.Entity.ID = ci.attrs["wtmdata"].ID;
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateProductionOrder.vmModel.Entity.ID = useRouter().currentRoute.value.query.id as any;
	}
	productionorderApi().get(stateProductionOrder.vmModel.Entity.ID ?? "").then((data: any) => other.setValue(stateProductionOrder.vmModel, data));
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

